package cn.e4j.modular.system.mapper;

import cn.e4j.modular.system.entity.SysUserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户-角色关联表 Mapper 接口
 * </p>
 *
 * @author wenchuan.li
 * @since 2018-12-06
 */
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {

    /**
     * 根据用户id获取对应的角色List
     *
     * @param id
     * @return
     */
    @Select("select ROLE_ID from SYS_USER_ROLE where USER_ID = #{id} order by ROLE_ID asc")
    List<Map<String, String>> selectRoleidsByUser(@Param("id") String id);

    /**
     * 根据角色id获取对应的用户List
     *
     * @param id
     * @return
     */
    @Select("select USER_ID from SYS_USER_ROLE where ROLE_ID = #{id} order by USER_ID asc")
    List<Map<String, String>> selectUseridsByRole(@Param("id") String id);

}
